/*
 * Copyright the original author or authors.
 * 
 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.mozilla.org/MPL/MPL-1.1.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 package com.blitscreen.gesture.strategy
{
	import com.blitscreen.render.BlitSprite;
	
	/**
	 * The <code>BoundingBoxHit</code> strategy detects mouse collision
	 * by comparison with the bounding box of the sprite.
	 * 
	 * @author	Cédric Néhémie
	 * @see		GestureHitMode
	 */
	public class BoundingBoxHit implements GestureHitMode
	{
		/**
		 * @inheritDoc
		 */
		public function isTouched( mouseX : Number, mouseY : Number, sprite : BlitSprite ) : Boolean
		{
			var minx : Number = sprite.position.x - sprite.center.x;
			var miny : Number = sprite.position.y - sprite.center.y;
			var maxx : Number = sprite.area.width + minx;
			var maxy : Number = sprite.area.height + miny;
			
			return ( mouseX >= minx && mouseX <= maxx && mouseY >= miny && mouseY <= maxy );
		}
	}
}